<?php

	include './query.php';

	session_start();
	if ($_SESSION['username']) {
		var_dump($_SESSION);		
		$purchase = array();
		$purchase['phone'] = $_POST['phone'];
		$purchase['money'] = $_POST['amount'];
		$purchase['goods_count'] = $_POST['count'];
		$purchase['goods'] = $_POST['auction'];

		$ret = buy($purchase);
		error_log($ret == true ? "t" : 'f');
		if (! $ret) {
			$_SESSION['callback'] = '/wine/admin.php';
			header('Location: /wine/error.php');
		}

		header('Location: /wine/admin.php');
	}

	else {
		// not logged in yet
		header('Location: /wine/login.php');
	}
